define(function () {
  var jx = function () {
       $.get('./data/home.json',function(responseText,responseState,responseObj){
         //console.log(responseText[0]);
          var data = responseText[0].data;
          //console.log(data);
          var act_info = data.act_info;
           //console.log(act_info);
           var turn = act_info[0].act_rows;
           //console.log(turn);
           var str1 = '';
           for(var i in turn){
             //console.log(turn[i].activity);
             var img = turn[i].activity.img;
             //console.log(img);
             str1 += '<div>'+
                        '<img src='+img+' alt="">'+
                    '</div>'
           }
           $('#middle').html(str1);

           var lis1 = act_info[1].act_rows;
           //console.log(lis1);
           var str2 = '';
           for(var i in lis1){
             //console.log(turn[i].activity);
             var img = lis1[i].activity.img;
             var name = lis1[i].activity.name;
             //console.log(img);
            // console.log(name);
              str2 +=`<div>
                  <img src=`+img+` alt="">
                  <p>`+name+`</p>
                  </div>`
           }
           $('.lis1').html(str2);

           var pic1 = act_info[3].act_rows;
            //console.log(pic1)
            var str3 = '';
            for(var i=0;i<pic1.length-1;i++){
              var img = pic1[i].activity.img;
            //  console.log(img);
               str3 +=`<div>
                   <img src=`+img+` alt="">
                   </div>`
            }
            $('.pic1').html(str3);

            var bld = act_info[4].act_rows;
            //console.log(bld);
            var str4 = '';
            var str5 = '';
            var str6 = '';
            var str7 = '';
            for(var i in bld){
                if(i == 0){
                    var act_rows1 = bld[i].act_rows;
                    var img = act_rows1[0].chead_detail.img;
                    str4 +=` <div class="top">
                            <img src=`+img+` alt="">
                            </div>
                            <div class="m2">
                            </div>
                            <div class="m4">
                            </div>
                            <div class="bot">
                            </div>`
                }
                if(i == 1){
                    var act_rows2 = bld[i].act_rows;
                    //console.log(act_rows2);
                    for(var j in act_rows2){
                      var img = act_rows2[j].cactivity_detail.img;
                      //console.log(img)
                      str5 += `<div>
                                  <img src=`+img+` alt="">
                                </div>`
                    }
                }
                if(i == 2){
                    var act_rows3 = bld[i].act_rows;
                  //  console.log(act_rows3);
                    for(var j in act_rows3){
                      var img = act_rows3[j].cicons_detail.img;
                      var name = act_rows3[j].cicons_detail.name;
                    //  console.log(img)
                      str6 += `<div>
                                  <img src=`+img+` alt="">
                                  <p>`+name+`</p>
                              </div>`
                    }
                }
                if(i == 3){
                    var act_rows4 = bld[i].act_rows;
                   //console.log(act_rows4);
                    for(var j in act_rows4){
                      var img = act_rows4[j].activity.img;
                    //console.log(img)
                      str7 += `<div>
                                  <img src=`+img+` alt="">
                              </div>`
                    }
                }
            }
            $('.bld').html(str4);
            $('.m2').html(str5);
            $('.m4').html(str6);
            $('.bot').html(str7);
            var box1 = act_info[5].act_rows;
            var zfc = '';
            var zfc1 = '';
            for(var i in box1){
              var bi1 = box1[i].category_detail;
              var bi2 = box1[i].activity;
              var color = bi1.category_color;
              var goods = bi1.goods;
              var img1 = bi2.img;
              var name = bi1.name;
              zfc1 += `<div class="bi1">
                          <div>
                            <span style="background-color:#`+color+`"></span>
                            <p style="color:#`+color+`">`+name+`</p>
                          </div>
                          <div>
                            <p>更多</p>
                            <i class="icon iconfont icon-dayuhao1"></i>
                          </div>
                      </div>`
              zfc1 +=`<div class="bi2">
                          <img src=`+img1+` alt="">
                      </div>`
              var zfc3 = '';
              var zfc2 = '';
              for(var j in goods){
                var app_mimg = goods[j].app_mimg;
                var keywords = goods[j].keywords;
                var partner_price = goods[j].partner_price;
                var d_price = goods[j].d_price;
                var name = goods[j].name;
                var long_name = goods[j].long_name;
                var org_source_value = goods[j].org_source_value;
                var pm_desc = goods[j].pm_desc;
                var xl = long_name.substring(name.length,long_name.length);
                if(d_price == undefined){
                  if(org_source_value == 1){
                    if(pm_desc == ''){
                      zfc2 +=` <div>
                                    <img src=`+app_mimg+` alt="">
                                    <p>`+long_name+`</p>
                                    <span>精选</span>
                                    <h4>`+xl+`</h4>
                                    <h5>￥`+partner_price+`</h5>
                                    <div class="jia">
                                      <i class="icon iconfont icon-jiahao"></i>
                                    </div>
                                </div>`
                    }else {
                      zfc2 +=` <div>
                                    <img src=`+app_mimg+` alt="">
                                    <p>`+long_name+`</p>
                                    <span>精选</span><span style="background-color:red;color:#fff;margin-left:0.1rem">`+pm_desc+`</span>
                                    <h4>`+xl+`</h4>
                                    <h5>￥`+partner_price+`</h5>
                                    <div class="jia">
                                      <i class="icon iconfont icon-jiahao"></i>
                                    </div>
                                </div>`
                    }

                  }else {
                    zfc2 +=` <div>
                                  <img src=`+app_mimg+` alt="">
                                  <p>`+long_name+`</p>
                                    <span style='border:none'></span>
                                  <h4>`+xl+`</h4>
                                  <h5>￥`+partner_price+`</h5>
                                  <div class="jia">
                                    <i class="icon iconfont icon-jiahao"></i>
                                  </div>
                              </div>`
                  }

                }else {
                  if(org_source_value == 1){
                    if(pm_desc == ''){
                      zfc2 +=` <div>
                                    <img src=`+app_mimg+` alt="">
                                    <p>`+long_name+`</p>
                                    <span>精选</span>
                                    <h4>`+xl+`</h4>
                                    <h5>￥`+partner_price+` <a>￥`+d_price+`</a></h5>
                                    <div class="jia">
                                      <i class="icon iconfont icon-jiahao"></i>
                                    </div>
                                </div>`
                    }else {
                      zfc2 +=` <div>
                                    <img src=`+app_mimg+` alt="">
                                    <p>`+long_name+`</p>
                                    <span>精选</span><span style="background-color:red;color:#fff;margin-left:0.1rem">`+pm_desc+`</span>
                                    <h4>`+xl+`</h4>
                                    <h5>￥`+partner_price+` <a>￥`+d_price+`</a></h5>
                                    <div class="jia">
                                      <i class="icon iconfont icon-jiahao"></i>
                                    </div>
                                </div>`
                    }

                  }else {
                    zfc2 +=` <div>
                                  <img src=`+app_mimg+` alt="">
                                  <p>`+long_name+`</p>
                                  <span style='border:none'></span>
                                  <h4>`+xl+`</h4>
                                  <h5>￥`+partner_price+` <a>￥`+d_price+`</a></h5>
                                  <div class="jia">
                                    <i class="icon iconfont icon-jiahao"></i>
                                  </div>
                              </div>`
                  }

                }

              }
              var zfc3 =`<div class="bi3">`+zfc2+`</div>`;
              zfc1 += zfc3;
            }
            zfc +=`<div class="item">`+zfc1+`</div>`
            $('.box1').html(zfc);
       })
  }
  return {
      jx : jx
  };

})
